package cn.yunhe.entity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Entity(name = "订单")
@Table(name = "order2")
public class Order implements Serializable {
    private int id;
    private String orderdate;
    private double totalprice;
    private User user;

    private Set<OrderBook> orderBookSet=new HashSet<>();

    public Order() {
    }

    public Order(String orderdate, double totalprice) {
        this.orderdate = orderdate;
        this.totalprice = totalprice;
    }

    public Order(String orderdate, double totalprice, User user) {
        this.orderdate = orderdate;
        this.totalprice = totalprice;
        this.user = user;
    }

    public Order(int id, String orderdate, double totalprice, User user) {
        this.id = id;
        this.orderdate = orderdate;
        this.totalprice = totalprice;
        this.user = user;
    }

    @Id
    @GeneratedValue
    @Column(name = "id")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "orderdate")
    public String getOrderdate() {
        return orderdate;
    }

    public void setOrderdate(String orderdate) {
        this.orderdate = orderdate;
    }

    @Column(name = "totalprice")
    public double getTotalprice() {
        return totalprice;
    }

    public void setTotalprice(double totalprice) {
        this.totalprice = totalprice;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ouid")
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "ooid")
    public Set<OrderBook> getOrderBookSet() {
        return orderBookSet;
    }

    public void setOrderBookSet(Set<OrderBook> orderBookSet) {
        this.orderBookSet = orderBookSet;
    }
}
